import { Modal } from 'antd'
import React from 'react'
import { useTranslation } from 'react-i18next'

const Dialog = (props: any) => {
  const { t } = useTranslation()
  const { width, title, open, onOk, onCancel } = props
  const children = React.Children.toArray(props?.children)

  return (
    <Modal
      width={width}
      title={title}
      centered
      open={open}
      onOk={onOk}
      onCancel={onCancel}
      forceRender={true}
      okText={t('users.addOrEditModel.okText')}
      cancelText={t('users.addOrEditModel.cancelText')}
    >
      {children.map((item: any, index: number) => {
        return <React.Fragment key={index}>{item}</React.Fragment>
      })}
    </Modal>
  )
}

export default Dialog
